package com.kalle.workflow.query;

import java.util.List;

public abstract class AbstractQuery<T> {

    abstract List<T> list();

    public T unique() {
        List<T> results = list();
        if (results.isEmpty()) {
            return null;
        }
        if (results.size() > 1) {
            throw new RuntimeException("More than one result found in database.");
        }
        return results.get(0);
    }

}
